public class Method {
    public static void main(String[] args){
        //基本四则运算：+-*/
        int a = 10;
        int b = 20;
        System.out.println(a + b);
        System.out.println(b / a);
        System.out.println(a * b);
        System.out.println(a - b);
        //取整与取模运算：
        System.out.println(a / b);
        System.out.println(a * 1.0 / b);
        System.out.println(a % b);

        //做除法和取模时，右操作数不能为0：
        /*int b1 = 0;
        System.out.println(a / b1);
        System.out.println(a % b1);
        会出现报错！
         */
        System.out.println(1 + 0.2);
        //操作数类型不一致时，会向类型大的提升

        //增量运算符：
        int a1 = 5;
        a1 += 3;
        System.out.println(a1);
        a1 -= 2;
        System.out.println(a1);
        a1 *= 3;
        System.out.println(a1);
        a1 /= 5;
        System.out.println(a1);
        a1 %= 2;
        System.out.println(a1);
        //自增/自减运算符：
        int b1 = 3;
        System.out.println(b1);
        System.out.println(b1++);
        int b2 = 3;
        ++b2;
        System.out.println(b2);
        System.out.println(++b2);
        //关系运算符：
        int a2 = 33;
        int b3 = 40;
        System.out.println(a2 == b3);
        System.out.println(a2 > b3);
        System.out.println(a2 >= b3);
        System.out.println(a2 < b3);
        System.out.println(a2 <= b3);
        System.out.println(a2 != b3);
        //逻辑运算符：
        System.out.println(a2 < b3 && a2 == b3);
        System.out.println(a2 < b3 && a2 != b3);
        System.out.println(a2 <= b3 || a2 == b3);
        System.out.println(a2 != b3 || a2 > b3);
        //位运算符：
        int m = 10;
        int n = 20;
        System.out.println(a & b);//两个二进制位都为1，则为1
        System.out.println(a | b);//两个二进制为都为0，则为0
        System.out.println(~m);//1转0，0转1
        System.out.println(m ^ n);//相同为0，相异为1
        //移位运算符：
        int j = 0x10;
        System.out.printf("%x\n",j<<1);
        //最左侧不要，最右侧补1
        System.out.printf("%x\n",j>>1);
        //最右侧不要，最左侧补符号位
        System.out.printf("%x\n",j>>>1);
        //最右侧不要，最左侧补0

        //条件运算符：
        int max = a > b ? a : b;
        System.out.println(max);

    }
}
